# Contributor: Teemu Nätkinniemi ("teepean") <tnatkinn@gmail.com>
_realname=isa-l
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.30.0
pkgrel=1
pkgdesc="A collection of optimized low-level functions targeting storage applications (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64')
url="https://github.com/intel/isa-l"
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-libdeflate")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-yasm")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/intel/${_realname}/archive/refs/tags/v${pkgver}.tar.gz")
sha256sums=('bcf592c04fdfa19e723d2adf53d3e0f4efd5b956bb618fed54a1108d76a6eb56')

prepare(){
  cd "${srcdir}/${_realname}-${pkgver}"
  # dont allow undefined symbols to build the dll
  sed -i "87ilibisal_la_LDFLAGS = -no-undefined" Makefile.am
  ./autogen.sh
}

build() {
  [[ -d "build-${MSYSTEM}" ]] && rm -rf "build-${MSYSTEM}"
  mkdir -p "${srcdir}/build-${MSYSTEM}"
  cd "${srcdir}/build-${MSYSTEM}"

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

check() {
    cd "${srcdir}/build-${MSYSTEM}"
    make check
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR=${pkgdir} install
}
